{% extends "element/saas/base_mini.html" %}
{% load future wenlincms_tags staticfiles wlcore_tags %}

{% block meta_title %}企业征信报告检索结果{% endblock %}

{% block header %}{% endblock %}
{% block footer %}{% endblock %}

{% block wlmain %}
    <style>
        body, html {
            background-color: #fff;
            height: auto;
        }
    </style>
    <div id="re_search">
        <div class="re_selected_box">
            <ul class="re_selected">
                <li>搜索结果：</li>
                <li style="border:none;">共<span class="numBox">-</span>条数据</li>
            </ul>
            {% if selected %}
                <ul class="re_selected">
                    <li>搜索条件：</li>
                    {% for sd in selected %}
                        <li>{{ sd }}</li>
                    {% endfor %}
                </ul>
            {% endif %}
        </div>

        <table class="re_search_table">
            <thead>
            <tr style="background-color: #f7f7f7;">
                <th style="text-align: left;" width="54%">企业名称等信息</th>
                <th class="text-center" width="11%">企业状态</th>
                <th class="text-center" width="11%">注册资本(万)</th>
                <th class="text-center" width="11%">查看报告</th>
                <th class="text-center" width="11%">更多操作</th>
            </tr>
            </thead>
            <tbody id="re_comlist"></tbody>
        </table>

        <ul data-am-widget="pagination" class="am-pagination am-pagination-default saas_pagination" id="re_pagination">
            <li class="am-pagination-prev preBtn">
                <a href="javascript:void(0)">上一页</a>
            </li>
            <li class="am-pagination-next nextBtn">
                <a href="javascript:void(0)">下一页</a>
            </li>
            <li class="jumpPage">
                <div class="inBox">
                    跳转 <input class="mini-textbox" vtype="int" name="numinput"
                              width="60" height="30"/>&nbsp;&nbsp;/<em class="numBox">-</em>页
                </div>
                <em class="jumpbtn">确定</em>
            </li>
        </ul>
    </div>
    <img src="/static/element/report/imgs/loading.gif" id="loadingimg" style="display: block;">
{% endblock %}

{% block footer_js %}
    {{ block.super }}
    <script>
        mini.parse();
        if (window.Owner) {
            var tabs = window.Owner.mini.get("mainTabs");
        }
        resulthei();
        //搜索结果页跳转报告
        var pageIndex = getQueryString("pageIndex"),
            sortField = getQueryString("sortField"),
            sortOrder = getQueryString("sortOrder"),
            sfield = 'ENTNAME￥REGNO￥region_id￥nic_id￥elseic_id￥ENTSTATUS￥ENTTYPE￥OPSCOPE￥REGCAP' +
                '￥ESDATE￥revenue￥total_profit￥assets_re￥timport￥texport',
            currentNum,
            svalue = getQueryString("svalue");
        if (!pageIndex) {
            pageIndex = 0
        }
        if (!svalue) {
            sfield = "";
            svalue = "";
        }
        if (sortField == '0') {
            sortField = "";
            sortOrder = "";
        }
        //动态列表
        var re_comlist = $("#re_comlist");
        var getList = function (num) {
            re_comlist.html("");
            $("#loadingimg").show();
            $(window.parent.document.body).scrollTop(0);
            $.ajax({
                type: 'POST',
                url: '/saas/company_list/?method=loadtable',
                data: {
                    pageIndex: num,
                    pageSize: 20,
                    sfield: sfield,
                    svalue: svalue,
                    sortOrder: sortOrder,
                    sortField: sortField
                },
                success: function (response) {
                    var res = response,
                        total = res.total,
                        pageallNum = Math.ceil(total / 20),
                        data = res.data;
                    $(".re_selected .numBox").text(total);
                    for (var i = 0, len = data.length; i < len; i++) {
                        var rethis = data[i];
                        var entstatushtml = '';
                        if (rethis.ENTSTATUS == '在营（开业）') {
                            entstatushtml = '<span class="am-badge am-badge-success">' + rethis.ENTSTATUS + '</span>';
                        }
                        else {
                            entstatushtml = '<span class="am-badge">' + rethis.ENTSTATUS + '</span>';
                        }
                        var morehtml = '<span class="mini-button-icon icon-feed_add" onclick="">关注</span><br />' +
                            '<span class="mini-button-icon icon-chart_line" onclick="elchart(' + "'" + rethis.ENTNAME + "','" + rethis.entid + "','1'" + ')">图谱</span>';
                        var html = '<tr class="re_searchlist">'
                            + '<td class="re_info2">'
                            + '<span class="clear">'
                            + '<a href="javascript:void(0)" class="re_title" onclick="re_report(' + "'" + rethis.ENTNAME + "','" + rethis.entid + "','10'" + ')">' + rethis.ENTNAME + '</a>'
                            + '</span>'
                            + '<small class="clear">'
                            + '<span class="mr25 re_name">注册号：' + rethis.REGNO + '</span>'
                            + '<span class="mr25 re_name">法人：' + rethis.faren + '</span>';
                        if (rethis.enttel) {
                            html = html + '<span class="mr25 re_name">企业电话：' + rethis.enttel + '</span>';
                        }
                        if (rethis.farentel) {
                            html = html + '<span class="re_name">法人电话：' + rethis.farentel + '</span>';
                        }
                        html = html + '</small>'
                            + '<small class="clear">'
                            + '<span class="mr25"><i class="re_icon am-icon-location-arrow"></i>地区：' + rethis.region_id + '</span>'
                            + '<span><i class="re_icon am-icon-laptop"></i>行业：' + rethis.nic_id + '</span>'
                            + '</small>'
                            + '</td>'
                            + '<td class="re_info4">' + entstatushtml + '</td>'
                            + '<td class="re_info3">' + Math.round(rethis.REGCAP) + '</td>'
                            + '<td class="re_info5"><span class="mini-button-icon icon-report10" onclick="re_report(' + "'" + rethis.ENTNAME + "','" + rethis.entid + "','10'" + ')">全景版</span><br />'
                            + '<span class="mini-button-icon icon-report11" onclick="re_report(' + "'" + rethis.ENTNAME + "','" + rethis.entid + "','11'" + ')">标准版</span><br />'
                            + '<td class="re_info5">' + morehtml + '</td>'
                            + '</tr>';
                        re_comlist.append(html);
                    }
                    pageTool(pageallNum, num, "re_pagination");
                    $("#loadingimg").hide();
                    resulthei();
                }
            });
            currentNum = num;
        };
        getList(0);
        function re_report(title, url, v) {
            newtab("报告: " + title, '/report/' + url + '/?version=' + v, 'icon-report' + v);
        }
        function elchart(title, url, v) {
            newtab("图谱: " + title, '/report/' + url + '/tupu/?dstyle=' + v, 'icon-chart_line');
        }
        $(".jumpbtn").click(function () {
            jumpage(currentNum, getList, "numinput");
        });
        function resulthei() {
            if (window.Owner) {
                var tabs = window.Owner.mini.get("mainTabs");
                var tab = tabs.getTab("主数据表");
                var iframe = tabs.getTabIFrameEl(tab);
                var hei = iframe.contentWindow.document.body.scrollHeight + 150;
                if (hei < 700) {
                    hei = 700;
                }
                iframe.style.height = hei + 'px';
            }
        }
    </script>
{% endblock %}
